<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>SessionStorage</title>
	</head>
	<body>
		<h2>SessionStorage</h2>
		<button onclick="saveData()">点我保存一个数据</button>
		<button onclick="readData()">点我读取一个数据</button>
		<button onclick="delData()">点我删除一个数据</button>
		<button onclick="deleteAll()">点我清空数据</button>
		<script>
			function saveData() {
				let p = {'name':'张三','age':18};
				SessionStorage.setItem('person',JSON.stringify(p));
				SessionStorage.setItem('msg','888888888');
				SessionStorage.setItem('name','张三');
			}
			function readData() {
				console.log(SessionStorage.getItem('name'))
				console.log(SessionStorage.getItem('msg4'))
				console.log(JSON.parse(SessionStorage.getItem('person4')))
			}
			function delData() {
				SessionStorage.removeItem('msg')
			}
			function deleteAll() {
				SessionStorage.clear();
			}
		</script>
	</body>
</html>